# -*- encoding: utf-8 -*-
"""
@File    : prototype.py
@Author  : lilong
@Time    : 2021/12/18 10:27 下午
"""

"""
克隆模式也叫原型模式，通过拷贝自身的属性来创建一个新的对象。
"""

from copy import copy, deepcopy


class Person:
    def __init__(self, name, age):
        self.__name = name
        self.__age = age

    def showInfo(self):
        print("我是" + self.__name + ",今年年龄是" + str(self.__age) + "岁")

    def clone(self):
        return copy(self)


def test():
    tom = Person("Tom", 27)
    tom.showInfo()

    jeery = tom.clone()
    jeery.showInfo()


# 测试
test()
